package com.lxy.dataservice.service;

import com.lxy.dataservice.constants.MessageConstants;
import com.lxy.dataservice.dao.TestDao;
import com.lxy.dataservice.entity.Test;
import com.nip.db.mongodb.utils.tips.Response;
import com.nip.db.mongodb.utils.tips.ResponseCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * TestService
 *
 * @author < a href=" ">ZhangYang</ a>
 * @version v1.0.01
 * @date 2019-12-31 12:49
 */
@Service
public class TestService {
  @Autowired
  private TestDao testDao;

  public Response saveTest(Test entity) {
    try {
      testDao.save(entity);
      return new Response(ResponseCode.CODE_200, MessageConstants.SUCCESS);
    } catch (Exception e) {
      return new Response(ResponseCode.CODE_202, e.getMessage());
    }
  }

  public List<Test> findAllTest() {
    return testDao.findAll();
  }
}
